package com.butterfly.vv.view.clistmenu;

import java.util.ArrayList;
import java.util.List;

import com.beem.project.beem.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomAdapter extends BaseAdapter {
		
		static final int[] ICONS = new int[]{

			R.drawable.ic_menu_add,
			//R.drawable.ic_menu_invite,
			R.drawable.ic_menu_chat_dashboard,
			//android.R.drawable.ic_menu_info_details,
			R.drawable.ic_menu_chat_dashboard,
			R.drawable.ic_menu_chat_dashboard,
			R.drawable.ic_menu_manage,
			R.drawable.ic_menu_close_clear_cancel
			
		};
		
		static final int[] TITLES = new int[]{

			R.string.contact_list_menu_add_contact,
			R.string.contact_list_menu_search_contact,
			R.string.contact_list_menu_status,
			R.string.chat_menu_change_chat,
			R.string.contact_list_menu_settings,
			R.string.contact_list_menu_disconnect
			
		};

		LayoutInflater mLayoutInflater;
		List<ActionItemText> mItems;

		public CustomAdapter( Context context ) {
			mLayoutInflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

			mItems = new ArrayList<ActionItemText>();
			//20130130int total = (int) (4 + (Math.random() * 30));
			int total = (int) ((6));

			for( int i = 0; i < total; i++ ) {
				ActionItemText item = new ActionItemText( context, TITLES[i], ICONS[ i ] );
				mItems.add( item );
			}
		}
		

		@Override
		public int getCount() {
			return mItems.size();
		}

		@Override
		public Object getItem( int arg0 ) {
			return mItems.get( arg0 );
		}

		@Override
		public long getItemId( int arg0 ) {
			return arg0;
		}

		@Override
		public View getView( int position, View arg1, ViewGroup arg2 ) {
			View view = mLayoutInflater.inflate( R.layout.action_item, arg2, false );

			ActionItemText item = (ActionItemText) getItem( position );

			ImageView image = (ImageView) view.findViewById( R.id.image );
			TextView text = (TextView) view.findViewById( R.id.title );

			image.setImageDrawable( item.getIcon() );
			text.setText( item.getTitle() );

			return view;
		}

	}